<template>
  <view class="h_body mine">
    <view class="mine_tx">
      <image src="@/assets/images/index/wode_icon_touxiang.png"></image>
      <view v-if="userStore.userInfo.phone">{{ userStore.userInfo.phone || '' }}</view>
      <view v-else @click="toLogin">请登录</view>
    </view>
    <view class="h_card mine_body">
      <view class="address_div" @touchstart="navAdressBook">
        <image src="@/assets/images/index/wode_icon_dizhibu.png"></image>
        <view class="text">
          <view class="t">地址簿</view>
          <view class="b">管理您的地址信息</view>
        </view>
      </view>
      <view class="address_div" @touchstart="navCodePage">
        <image src="@/assets/images/index/wode_icon_gehzongma.png"></image>
        <view class="text">
          <view class="t">取/发货码</view>
          <view class="b">查看您的取/发货码</view>
        </view>
      </view>
    </view>
    <view class=" h_card mine_contant">
      <view class="mine_row" @click="gotoMyNotification">
        <Notice />
        <nut-badge :value="3">
          <view class="text">我的通知</view>
        </nut-badge>
      </view>
      <view class="mine_row" @click="gotoMyInvoice">
        <Order />
        <view class="text">我的发票</view>
      </view>
      <view class="mine_row" @click="gotoMyBankAccount">
        <Eye />
        <view class="text">银行账户</view>
      </view>
      <view class="mine_row" @click="gotoMyTitle">
        <Service />
        <view class="text">发票抬头</view>
      </view>
    </view>
    <view class="h_card mine_foot" @click="logout" v-if="userStore.userInfo.phone">退出登录</view>
  </view>
</template>
<script lang="ts" setup>
import { Notice, Eye, Order, Service } from "@nutui/icons-vue-taro";
import Taro from '@tarojs/taro';
import useUserInfoStore from "@/store/user"
import { $get, noUserToLogin, checkLogin } from "@/@api";
const userStore = useUserInfoStore()
const navCodePage = () => {
  noUserToLogin()
  Taro.navigateTo({
    url: '/pages/codeList/codeList'
  })
}
const navAdressBook = () => {
  noUserToLogin()
  Taro.navigateTo({
    url: '/pages/addressBook/index'
  })
}
function gotoMyTitle() {
  noUserToLogin()
  Taro.navigateTo({
    url: '/pages/invoicing/myTitle'
  })
}
function gotoMyNotification() {
  noUserToLogin()
  Taro.navigateTo({
    url: '/pages/myNotification/index'
  })
}
function gotoMyBankAccount() {
  noUserToLogin()
  Taro.navigateTo({
    url: '/pages/myBankAccount/index'
  })
}
function gotoMyInvoice() {
  noUserToLogin()
  Taro.navigateTo({
    url: '/pages/invoicing/myInvoice'
  })
}
function logout() {
  Taro.showModal({
    title: '确定退出登录？',
    confirmColor: "#fa5151",
    success: (res) => {
      if (res.confirm) {
        console.log("退出成功");
        Taro.removeStorageSync('userToken')
        Taro.removeStorageSync('openid')
        Taro.removeStorageSync('userInfo')
        userStore.removeToken()
        userStore.removeOpenid()
        userStore.removeUserinfo()
        Taro.reLaunch({
          url: `/pages/login/index`,
        })
      }

    }
  })
}
function toLogin() {
  Taro.navigateTo({
    url: '/pages/login/index'
  })
}

checkLogin()
</script>
<style lang="scss">
.mine .mine_contant .mine_row:before {
  position: absolute;
  top: 0;
  right: 30rpx;
  bottom: 0;
  display: block;
  margin: auto;
  width: 30rpx;
  height: 30rpx;
  color: #8799a3;
  content: "\e6a3";
  text-align: center;
  font-size: 34rpx;
  font-family: cuIcon;
  line-height: 30rpx;
}

.mine {
  background: url("../../assets/images/index/wode_img_beijing.png") no-repeat;
  background-size: cover;

  .mine_tx {
    height: 104rpx;
    display: flex;
    align-items: center;
    font-family: PingFang SC;
    font-size: 32rpx;
    color: #252525;
    margin-left: 24rpx;
    margin-top: 160rpx;
    font-weight: 700;

    image {
      width: 104rpx;
      height: 104rpx;
      margin-right: 16rpx;
    }
  }

  .mine_body {
    height: 152rpx;
    margin-top: 24rpx;
    display: flex;

    .address_div {
      width: 50%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;

      image {
        width: 72rpx;
        height: 72rpx;
        margin-right: 16rpx;
      }

      .text {
        font-family: PingFang SC;
        height: 72rpx;

        .t {
          font-weight: 700;
          font-size: 28rpx;
          color: #252525;
        }

        .b {
          font-size: 20rpx;
          color: #999999;
        }
      }
    }
  }

  .mine_contant {
    height: 416rpx;
    margin-top: 24rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    .mine_row {
      width: 654rpx;
      height: 103rpx;
      border-bottom: 1rpx solid rgba(0, 0, 0, 0.06);
      display: flex;
      align-items: center;
      position: relative;

      // justify-content: space-between;
      .text {
        font-family: PingFang SC Medium;
        font-size: 28rpx;
        margin-left: 24rpx;
        font-weight: 700;
        color: #252525;
        padding-right: 20rpx;
      }
    }

    .mine_row:nth-child(4) {
      width: 654rpx;
      height: 104rpx;
      border-bottom: unset;
    }
  }

  .mine_foot {
    height: 104rpx;
    margin-top: 24rpx;

    font-family: PingFang SC Medium;
    font-size: 28rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fa5151;
  }
}
</style>